<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

    function out_json($identifier, $label, $sql) {
        $CI = &get_instance();
        $CI->load->database();
        $CI->db->select($sql);
        $items = $CI->db->get()->result_array();        
        $out = '{"identifier":"'.$identifier.'",';

        $out .= '"label":"'.$label.'",';
        $out .= '"items":'.json_encode($items).'}';
        return $out;
    }  